#include "angajat.h"
#include <iostream>
#include <string.h>
#include <iomanip>
using namespace std;

Date::Date(int dd,int mm,int yy){
		
	if (mm>=1&&mm<=12)
	{
		 (*this).month=mm;
	}
	else
	{
	 cout<<"Invalid date! will be set to 1!";
	 (*this).month=1;
	}
	(*this).year=yy;

	(*this).day=checkDay(dd);

	cout<<"Constructor: \n";
	print();
	cout<<"\n";
}		
void Date::print()const{
cout<<setfill('0')<<setw(2)<<(*this).day<<"/"<<setfill('0')<<setw(2)<<(*this).month<<"/"<<setfill('0')<<setw(2)<<(*this).year<<"\n";
}
Date::~Date(){
cout<<"Destructor :";
print();
cout<<"\n";
}
int Date::getD()const{
return (*this).day;
}
int Date::getY()const{
return (*this).year;
}
int Date::getM()const{
return (*this).month;
}
int Date::checkDay(int x)const{
return x;
}
Angajat::Angajat(const char* fname ,const char* lname ,const Date& birth,const Date& hire):birthdate(birth),hiredate(hire){
int l=strlen(fname);
l=(l<25?l:24);
strncpy(firstname,fname,l);
firstname[l]='\0';
int ll=strlen(lname);
ll=(ll<25?ll:24);
strncpy(lastname,lname,ll);
lastname[ll]='\0';
}

void Angajat::print()const{
cout<<"Name "<<(*this).firstname<<" "<<(*this).lastname<<" Date of birth= ";
(*this).birthdate.print();
cout<<"Date of hire= ";
(*this).hiredate.print();

}

Angajat::~Angajat(){
cout<<"\nDestructor ";
print();
}

